Locale (locale.h)

Contents|Index|Previous|Next
Locale (locale.h)

A locale is the name for a collection of parameters (affecting collating sequences and formatting conventions) that may be different depending on location or culture. The C locale is the only one defined in the ANSI C standard.

This is a minimal implementation, supporting only the required C value for locale; strings representing other locales are not honored. is also accepted; it represents the default locale for an implementation, C being equivalent. See setlocale, localeconv for more discussion.

locale.h defines the structure, lconv, to collect the information on a locale, with the following fields.

char *decimal_point

The decimal point character used to format ordinary numbers (all numbers except those referring to amounts of money). . in the C locale.

char *thousands_sep

The character (if any) used to separate groups of digits, when formatting ordinary numbers. in the C locale.

char *grouping

Specifications for how many digits to group (if any grouping is done at all) when formatting ordinary numbers. The numeric value of each character in the string represents the number of digits for the next group, and a value of 0 (that is, the strings trailing NULL) means to continue grouping digits using the last value specified. Use CHAR_MAX to indicate that no further grouping is desired. in the C locale.

char *int_curr_symbol

The international currency symbol (first three characters), if any, and the character used to separate it from numbers. in the C locale.

char *currency_symbol

The local currency symbol, if any. in the C locale.

char*mon_decimal_point

The symbol used to delimit fractions in amounts of money. in the C locale.

char *mon_thousands_sep

Similar to thousands_sep, but used for amounts of money. in the C locale.

char *mon_grouping

Similar to grouping, but used for amounts of money. in the C locale.

char *positive_sign

A string to flag positive amounts of money when formatting. in the C locale.

char *negative_sign

A string to flag negative amounts of money when formatting. in the C locale.

char int_frac_digits

The number of digits to display when formatting amounts of money to international conventions. CHAR_MAX (the largest number representative as a char) in the C locale.

char frac_digits

The number of digits to display when formatting amounts of money to local conventions. CHAR_MAX in the C locale.

char p_cs_precedes

1 indicates the local currency symbol is used before a positive or zero formatted amount of money; 0 indicates the currency symbol is placed after the formatted number. CHAR_MAX in the C locale.

char p_sep_by_space

1 indicates the local currency symbol must be separated from positive or zero numbers by a space; 0 indicates that it is immediately adjacent to numbers. CHAR_MAX in the C locale.

char n_cs_precedes

1 indicates the local currency symbol is used before a negative formatted amount of money; 0 indicates the currency symbol is placed after the formatted number. CHAR_MAX in the C locale.

char n_sep_by_space

1 indicates the local currency symbol must be separated from negative numbers by a space; 0 indicates that it is immediately adjacent to numbers. CHAR_MAX in the C locale.

char p_sign_posn

Controls the position of the positive sign for numbers representing money. 0 means parentheses surround the number; 1 means the sign is placed before both the number and the currency symbol; 2 means the sign is placed after both the number and the currency symbol; 3 means the sign is placed just before the currency symbol; and 4 means the sign is placed just after the currency symbol. CHAR_MAX in the C locale.

char n_sign_posn

Controls the position of the negative sign for numbers representing money, using the same rules as p_sign_posn. CHAR_ MAX in the C locale.

Top|Contents|Index|Previous|Next